package com.han.spring.mvc._0143_Handler_Methods;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.runners.Parameterized.UseParametersRunnerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttribute;
import org.springframework.web.bind.annotation.SessionAttributes;

/**
* @author hanpeng
* @version 创建时间：2020年8月2日 下午8:56:29
* @ClassName 类名称
* @Description 类描述
*/
@SessionAttributes(names={"user"},types= {User.class})
@Controller
public class SessionAttributesController {
	private  static Log log = LogFactory.getLog(SessionAttributesController.class);
	private  static final String SUCCESS="success";
	@RequestMapping("/sessionAttributes")
	public String sessionAttributes(Model model) {
		System.out.println(model);
		model.addAttribute("user", new User("ds", 12222));
		return SUCCESS;
	}
	@RequestMapping("/sessionAttribute")
	public String sessionAttribute(@SessionAttribute(name="user",required=true) User user) {
		System.out.println(user);
		//RequestContextUtils.
		return SUCCESS;
	}
}
